﻿using System.Windows.Forms;

namespace Liwey.Common
{
    public class Msg
    {
        public static void Error(string msg, params object[] args)
        {
            error(msg, "错误", args);
        }

        private static void error(string msg, string title, params object[] args)
        {
            MessageBox.Show(string.Format(msg, args), title, MessageBoxButtons.OK, MessageBoxIcon.Error);
        }

        public static void Warn(string msg, params object[] args)
        {
            warn(msg, "警告", args);
        }

        private static void warn(string msg, string title, params object[] args)
        {
            MessageBox.Show(string.Format(msg, args), title, MessageBoxButtons.OK, MessageBoxIcon.Warning);
        }

        public static void Help(string msg, params object[] args)
        {
            info(msg, "帮助", args);
        }

        public static void Info(string msg, params object[] args)
        {
            info(msg, "提示", args);
        }

        private static void info(string msg, string title, params object[] args)
        {
            MessageBox.Show(string.Format(msg, args), title, MessageBoxButtons.OK, MessageBoxIcon.Information);
        }

        public static DialogResult Confirm(string msg, params object[] args)
        {
            return confirm(msg, "确认", args);
        }

        private static DialogResult confirm(string msg, string title, params object[] args)
        {
            return MessageBox.Show(string.Format(msg, args), title, MessageBoxButtons.OKCancel, MessageBoxIcon.Question);
        }

        public static DialogResult Ask(string msg, params object[] args)
        {
            return ask3(msg, "确认", args);
        }

        private static DialogResult ask3(string msg, string title, params object[] args)
        {
            return MessageBox.Show(string.Format(msg, args), title, MessageBoxButtons.YesNoCancel, MessageBoxIcon.Question);
        }
    }
}
